import express from 'express';
import { Mongoose } from 'mongoose';
import postRoutes from './routes/posts.js';
import usersRoutes from './routes/users.js';
const app = express();

app.use(express.json());
app.use(expressurlencode())

app.use('posts', postRoutes);
app.use('users', usersRoutes);

const PORT = process.env.PORT || 5000 ;

app.get("/", (req,res)=>{
    res.send("hello to our blog project api")
})

// app.listen(
//     PORT, ()=> console.log('server is running on port ${PORT}')
// )

Mongoose.connect(DB_RUL)
    .then (() => app.listen(PORT, ()=> console.log('server is running on port ${PORT}')))
    .catch((error) => console.log('${error} did not connect')) ;